package bairui.international.model.domain.jpa;

/**
 *
 * @see TB_Address 地址
 *
 */
public class TestData_TB_Address
{

	private final static org.apache.commons.text.RandomStringGenerator Generator = new org.apache.commons.text.RandomStringGenerator.Builder().withinRange(new char[][]{{'a','z'}, {'A','Z'}, {'0','9'}}).build();

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_Address saveMust(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_User user
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_Address");
		return (TB_Address)repository.save(newMust(
				user
			));
	}
	
	public static TB_Address newMust(
		bairui.international.model.domain.jpa.TB_User user
	){
		return new TB_Address(new TB_Address.MustProperties() {
			/** 姓名 */
			@Override public String getName(){
				return Generator.generate(0, 30);
			}
			/** 电话 */
			@Override public String getPhone(){
				return Generator.generate(0, 255);
			}
			/** 地区 */
			@Override public String getArea(){
				return Generator.generate(0, 255);
			}
			/** 详细地址 */
			@Override public String getDetailAddress(){
				return Generator.generate(0, 255);
			}
			/** 用户 */
			@Override public bairui.international.model.domain.jpa.TB_User getUser(){
				return user;
			}
			/** 县ID */
			@Override public Long getTownId(){
				return com.sh_lianjing.test.random.Util_GenerateRandom.longRandom(Long.MIN_VALUE, Long.MAX_VALUE);
			}
			/** 默认标志 */
			@Override public Boolean getDefaultFlag(){
				return new java.util.Random().nextBoolean();
			}
		});
	}
	

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_Address saveAll(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_User user
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_Address");
		return (TB_Address)repository.save(newAll(
				user
			));
	}
	
	public static TB_Address newAll(
		bairui.international.model.domain.jpa.TB_User user
	){
		return new TB_Address(
			new TB_Address.MustProperties() {
				/** 姓名 */
				@Override public String getName(){
					return Generator.generate(0, 30);
				}
				/** 电话 */
				@Override public String getPhone(){
					return Generator.generate(0, 255);
				}
				/** 地区 */
				@Override public String getArea(){
					return Generator.generate(0, 255);
				}
				/** 详细地址 */
				@Override public String getDetailAddress(){
					return Generator.generate(0, 255);
				}
				/** 用户 */
				@Override public bairui.international.model.domain.jpa.TB_User getUser(){
					return user;
				}
				/** 县ID */
				@Override public Long getTownId(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.longRandom(Long.MIN_VALUE, Long.MAX_VALUE);
				}
				/** 默认标志 */
				@Override public Boolean getDefaultFlag(){
					return new java.util.Random().nextBoolean();
				}
			},
			new TB_Address.OptionalSingleProperties() {
			}
		);
	}
	

}
